package cn.strive.eams.virtual.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.virtual.pojo.dto.VirtualQuery;
import cn.strive.eams.virtual.pojo.dto.VirtualSaveParam;
import cn.strive.eams.virtual.pojo.vo.VirtualVO;
import cn.strive.eams.virtual.service.VirtualService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/virtual")
public class VirtualController {
    @Autowired
    VirtualService virtualService;

    @GetMapping("/select")
    public JsonResult selectVirtual(VirtualQuery virtualQuery){
        log.debug("查询虚拟资产:virtualQuery={}",virtualQuery);
        List<VirtualVO> list = virtualService.selectVirtual(virtualQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("/save")
    public JsonResult saveVirtual(VirtualSaveParam virtualSaveParam){
        log.debug("保存虚拟资产:virtualSaveParam={}",virtualSaveParam);
        virtualService.saveVirtual(virtualSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{id}")
    public JsonResult deleteVirtual(@PathVariable Long id){
        log.debug("删除虚拟资产:id={}",id);
        virtualService.deleteVirtual(id);
        return JsonResult.ok();
    }
    @PostMapping("/delete/batch/{ids}")
    @ApiOperation(value = "批量删除虚拟资产")
    public JsonResult deleteBatch(@PathVariable List<Long> ids){
        log.info("批量删除虚拟资产信息:ids={}", ids);
        virtualService.deleteBatch(ids);
        return JsonResult.ok();
    }
}
